package com.chen.module.testproducerconsumer;

/**
 * create by chen on 2020/4/24 10:38
 * Email:chenshaopeng90@hotmail.com
 */
public class TestSync {
    public static void main(String[] args) {
        String a = "look";
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (TestSync.class) {
                    System.out.println("t start............");
                    try {
                        TestSync.class.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("t end............");
                }
            }
        });

        t.start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (TestSync.class) {
                    System.out.println("newThread start............");
                    try {
                        TestSync.class.notifyAll();
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("newThread end............");
                }
            }
        }).start();
    }
}
